import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Document } from "mongoose";
import { TagDocument } from "src/tag/shema/tag.shema";

export class Comment{
    from:string;
    to:string;
    content:string;
    time:Date;
}
export type ArticleDocument=Article & Document
@Schema()
export class Article {
    @Prop({required:true})
    title:string;
    @Prop({default:""})
    description:string;
    @Prop({default:""})
    author:string;
    @Prop({default:""})
    coverUrl:string;
    @Prop({default:""})
    typeId:string;
    @Prop({default:[]})
    tags:TagDocument[];
    @Prop({default:''})
    contentUrl:string;
    @Prop({default:'draft'})
    status:string;
    @Prop({default:[]})
    comments:Comment[];
    @Prop({default:0})
    views:number;
    @Prop({default:0})
    stars:number;
    @Prop({default:new Date().getTime()})
    updateTime:Date;
}
export const ArticleSchema=SchemaFactory.createForClass(Article)
